package ru.amse.stroganova.ui.tool;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseEvent;

import ru.amse.stroganova.ui.GraphComponent;
import ru.amse.stroganova.ui.tool.state.DefaultState;
import ru.amse.stroganova.ui.tool.state.ToolState;

/*package*/ class SelectTool extends Tool {
	
	private ToolState currentState;
	
	private final GraphComponent component;

	/*package*/ SelectTool(GraphComponent component) {
		this.component = component;
		currentState = new DefaultState(component, this);
	}

	@Override
	public void setState(ToolState state) {
		currentState = state;
	}
	
	@Override
	public void mousePressed(MouseEvent e) {
		currentState.mousePressed(e);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		currentState.mouseClicked(e);
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		currentState.mouseReleased(e);
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		currentState.mouseDragged(e);
	}
	
	@Override
	public void mouseEntered(MouseEvent e) {
		currentState.mouseEntered(e);
	}
	
	@Override
	public void mouseExited(MouseEvent e) {
		currentState.mouseExited(e);
	}
	
	@Override
	public void mouseMoved(MouseEvent e) {
		currentState.mouseMoved(e);
	}

	@Override
	public void finalActions() {
		currentState.finalActions();
	}
	
	/*package*/ void returnToInitialState() {
		currentState = new DefaultState(component, this);
	}
	
	/*package*/ void returnToInitialState(MouseEvent e) {
		currentState = new DefaultState(component, this);
		currentState.mousePressed(e);
	}
	
	@Override
	public void paint(Graphics g, Color backgroundColor) {
		currentState.paint(g, backgroundColor);
	}
}
